<?php

namespace app\api\controller;

use app\common\controller\ApiController;
use app\common\lib\Show;
use think\response\Json;

class Home extends ApiController
{
    public function getNewsList(): Json
    {
        if(!$this->request->isGet()){
            return Show::error([],'请求方式错误');
        }
        try {
            $list=\app\api\service\Home::getNewsList(1,10);
        }catch (\Exception $e){
            return Show::error([],$e->getMessage());
        }
        return Show::success($list);
    }
    public function getRecommendList(): Json
    {
        if(!$this->request->isGet()){
            return Show::error([],'请求方式错误');
        }
        try {
            $row=\app\api\service\Home::getRecommendList();
        }catch (\Exception $e){
            return Show::error([],$e->getMessage());
        }
        return Show::success($row);
    }
}